﻿using IRepository;

namespace Repository
{
    public class UserInfoRepository<T> : IUserInfoRepository<T> where T : class
    {
        private readonly MyContext context;

        public UserInfoRepository(MyContext context)
        {
            this.context = context;
        }
        public async Task<int> AddAsync(T t)
        {
            await context.Set<T>().AddAsync(t);
            return await context.SaveChangesAsync();
        }

        public async Task<int> DeleteAsync(T t)
        {
            context.Set<T>().Remove(t);
            return await context.SaveChangesAsync();
        }

        public IQueryable<T> GetAll()
        {
            return context.Set<T>();
        }

        public async Task<int> UpdateAsync(T t)
        {
            context.Set<T>().Update(t);
            return await context.SaveChangesAsync();
        }
    }
}
